<div id="boxes">
<?php
    $options=ceyloan_get_theme_options();
    if($options['bcat_1'] && $options['bcat_2'] && $options['bcat_3'] ){
        for($i=1;$i<=3;$i++){
            query_posts('category_name='.$options['bcat_'.$i].'&posts_per_page=1');
            if(have_posts ()){
                the_post();
                if($i==1){
                    echo '<div class="box rounded-corners" id="first"><h2>';
                }else if($i==2){
                    echo '<div class="box rounded-corners" id="second"><h2>';
                }else{
                    echo '<div class="box rounded-corners" id="last-box"><h2>';
                }
                the_title();
                echo '</h2><p>';
                the_excerpt();
                echo '</p></div>';
            }
        }
    }else{
	$categories=get_categories();
	$count=0;
	foreach($categories as $category){
		query_posts('category_name='.$category->name.'&posts_per_page=1');
		if(have_posts() && $count<3){
			the_post();
			$count++;
			if($count==3)
				echo '<div class="box rounded-corners" id="last-box"><h2>';
			elseif($count==2)
				echo '<div class="box rounded-corners" id="second"><h2>';
			else
				echo '<div class="box rounded-corners" id="first"><h2>';
			the_title();
			echo '</h2>';
			the_excerpt();
			echo '</div>';

		}
	}
    }
?>
<div class="clearfix"></div>
</div>